package org.resort.controller;

import org.resort.entity.Employee;
import org.resort.entity.RolePrivilege;
import org.resort.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * @Author 郭文虎
 */
@Controller
@RequestMapping("/common")
public class CommonController {
    @Autowired
    CommonService commonService;

    /**
     * 员工登录
     *
     * @param account  账号
     * @param password 密码
     * @param session  存储至全局作用域
     * @return 主页面(web-inf/jsp/common/index.jsp)
     */
    @RequestMapping("/employeeLogin.html")
    public String employeeLogin(String account, String password, HttpSession session) {
        Employee employee = commonService.employeeLogin(account, password);
        if (employee != null) {
            session.setAttribute("employee", employee);
            return "common/index";
        } else {
            return "common/error";
        }
    }

}
